package com.optimatch.model.solver;
import java.util.List;

import choco.cp.model.managers.IntConstraintManager;
import choco.kernel.model.variables.integer.IntegerVariable;
import choco.kernel.solver.Solver;
import choco.kernel.solver.constraints.SConstraint;
import choco.kernel.solver.variables.integer.IntDomainVar;


public class PropagatorManager extends IntConstraintManager {

	@Override
	public SConstraint makeConstraint(Solver solver, IntegerVariable[] variables,
			Object parameters, List<String> options) {
		
		Object[] par = (Object[]) parameters;
		int nbEquipes = (Integer) par[0];
		
		//TODO
		IntDomainVar[] vars = new IntDomainVar[2*(nbEquipes*(nbEquipes-1))];
		IntDomainVar[] match_vars = new IntDomainVar[nbEquipes*(nbEquipes-1)];
		IntDomainVar[] home_vars = new IntDomainVar[nbEquipes*(nbEquipes-1)];
		for(int i=0; i<match_vars.length; i++) {
			match_vars[i]=solver.getVar(variables[i]);
			home_vars[i] = solver.getVar(variables[nbEquipes*(nbEquipes-1)+i]);
			vars[i] = match_vars[i];
			vars[nbEquipes*(nbEquipes-1)+i] = home_vars[i];
		}

		return new Propagator(vars, match_vars, home_vars, nbEquipes);
	}

}
